#ifndef CLASSBROWSER_H
#define CLASSBROWSER_H

#include <wx/panel.h>
#include <M_Code_plugin.h>
#include <manager.h>
#include "cctreectrl.h"
#include "classbrowserbuilderthread.h"
#include "parser/parser.h"
#include "parser/token.h"

class NativeParser;
class wxComboBox;
class wxTreeCtrl;
class wxTextCtrl;
class M_Code_Project;
class ClassBrowser : public wxPanel {
  public:
    ClassBrowser( wxWindow* parent, NativeParser* np );
    virtual ~ClassBrowser();
    void  SetParser( ParserBase* parser );
    void  UpdateClassBrowserView( bool checkHeaderSwap = false );
    void  UpdateSash();
  private:
    void OnTreeItemDoubleClick( wxTreeEvent& event );
    void OnTreeItemRightClick( wxTreeEvent& event );
    void OnJumpTo( wxCommandEvent& event );
    void OnRefreshTree( wxCommandEvent& event );
    void OnForceReparse( wxCommandEvent& event );
    void OnCBViewMode( wxCommandEvent& event );
    void OnCBExpandNS( wxCommandEvent& event );
    void OnViewScope( wxCommandEvent& event );
    void OnDebugSmartSense( wxCommandEvent& event );
    void OnSetSortType( wxCommandEvent& event );
    void OnSearch( wxCommandEvent& event );
    bool FoundMatch( const wxString& search, wxTreeCtrl* tree, const wxTreeItemId& item );
    wxTreeItemId FindNext( const wxString& search, wxTreeCtrl* tree, const wxTreeItemId& start );
    wxTreeItemId FindChild( const wxString& search, wxTreeCtrl* tree, const wxTreeItemId& start, bool recurse = false, bool partialMatch = false );
    bool RecursiveSearch( const wxString& search, wxTreeCtrl* tree, const wxTreeItemId& parent, wxTreeItemId& result );
    void ShowMenu( wxTreeCtrl* tree, wxTreeItemId id, const wxPoint& pt );
    void ThreadedBuildTree( M_Code_Project* activeProject );
    void OnTreeItemExpanding( wxTreeEvent& event );
    void OnTreeItemCollapsing( wxTreeEvent& event );
    void OnTreeSelChanged( wxTreeEvent& event );
    void OnThreadEvent( wxCommandEvent& event );
  private:
    NativeParser* m_NativeParser;
    CCTreeCtrl* m_CCTreeCtrl;
    CCTreeCtrl* m_CCTreeCtrlBottom;
    wxTreeCtrl* m_TreeForPopupMenu;
    wxComboBox* m_Search;
    ParserBase* m_Parser;
    wxString m_ActiveFilename;
    wxSemaphore m_ClassBrowserSemaphore;
    ClassBrowserBuilderThread* m_ClassBrowserBuilderThread;

    DECLARE_EVENT_TABLE()
};

#endif
